package com.fieldchain.ex.fa100.utils.chart.dataset;

import android.graphics.Color;
import android.graphics.drawable.Drawable;

import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineDataSet;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by biyunlong
 * Email: 1225198434@qq.com
 * Data:  2018/8/24
 * 线条
 */
public class MkLindataSet extends LineDataSet {
    public static MkLindataSet builds(List<List<String>> list, Drawable drawable) {
        ArrayList<Entry> entryList = new ArrayList<>();
        for (int i = 0;i<list.size();i++) {
            Entry entry = new Entry();
            entry.setX(i);
            entry.setY(Float.parseFloat(list.get(i).get(1)));
            entryList.add(entry);
        }
        return new MkLindataSet(entryList, "", drawable);
    }

    public MkLindataSet(List<Entry> yVals, String label, Drawable drawable) {
        super(yVals, label);
        setColor(Color.parseColor("#FFDC3950"));
        setDrawCircles(false);
        setMode(Mode.LINEAR);
        setLineWidth(0.3f);
        setDrawFilled(true);
        setHighlightEnabled(false);
        setFillDrawable(drawable);
        setDrawValues(false);
    }
}
